#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_SIMPLE
#define D2D_REQUIRES_SCENE_POSITION
#include "d2d1effecthelpers.hlsli"

//阶段
float phase;
// 波幅
float amplitude;
//水波数量
float waveLength;
//半径
float radius;

//位置
float2 position;
float2 size;

D2D_PS_ENTRY(main) {

    //当前位置
    float2 cPoint = D2DGetScenePosition().xy;
    //获取当前点到水波点的距离
    float dist = distance(position,cPoint);
    if(radius >= dist){
        float amount = amplitude * sin(dist/waveLength*2*3.14159265-phase);
        amount =amount*(radius-dist)/radius;
        amount = amount*waveLength/(dist+0.0001);

        float dx = cPoint.x-position.x;
        float dy = cPoint.y -position.y;

        float tx = cPoint.x+dx*amount;
        float ty = cPoint.y+dy*amount;

        return  D2DSampleInputAtPosition(0,float2(tx,ty));
    }
    else{
        return D2DGetInput(0);
    }

    return D2DGetInput(0);
}



